<?php
function memberAnchors($members, $day, $memid = null, $url = '/report/index')
{
  $anchors = '';
  $format = '<a class="memberChart%s" href="%s" title="%s">%s</a> ';
  foreach($members as $member) {
    $title = 'View report from '.$member->getName().' between '.
    Util::getMonday($day).' and '.Util::getFriday($day);
    $sel = '';
    if ($memid == $member->getId()) $sel = ' selected';
    $link = $url.'?memid='.$member->getId();
    if ($day != null) $link .= '&day='.$day;
    $link = url_for($link);
    $name = $member->getName();
    $anchors .= sprintf($format, $sel, $link, $title, $name);
  }
  return $anchors;
}

function memberSelect($members, $memid = null)
{
  $anchors = '<select id="memberChart"><option value="-1">All</options>';
  $format = '<option value="%s" %s>%s</option> ';
  foreach($members as $member) {
    $sel = '';
    if ($memid == $member->getId()) $sel = 'selected="selected"';
    $anchors .= sprintf($format, $member->getId(), $sel, $member->getName());
  }
  return $anchors.'</select>';  
}

function chartTypeAnchors()
{
  $types = array(
    'Area2D' => 'FCF_Area2D.swf', 
    'Bar2D' => 'FCF_Bar2D.swf', 
    'Column2D' => 'FCF_Column2D.swf', 
    'Column3D' => 'FCF_Column3D.swf',
    'Line' => 'FCF_Line.swf',  
    'Pie2D' => 'FCF_Pie2D.swf',
    'Pie3D' => 'FCF_Pie3D.swf',

  );
  $typeMS = array(
    'MSArea2D' => 'FCF_MSArea2D.swf', 
    'MSBar2D' => 'FCF_MSBar2D.swf', 
    'MSColumn2D' => 'FCF_MSColumn2D.swf',
    'MSColumn3D' => 'FCF_MSColumn3D.swf', 
    'MSLine' => 'FCF_MSLine.swf',
  );
  $format = '<a class="chartType" href="#" title="%s">%s</a> ';
  $anchors = '';
  foreach($types as $type => $value) {
    $anchors .= sprintf($format, $value, $type);
  }
  $anchors .= '<br/>';
  foreach($typeMS as $type => $value) {
    $anchors .= sprintf($format, $value, $type);
  }
  return $anchors;
}

function chartTypeSelect($t = 'Column3D')
{
  $types = array(
    'Area2D' => 'FCF_Area2D.swf', 
    'Bar2D' => 'FCF_Bar2D.swf', 
    'Column2D' => 'FCF_Column2D.swf', 
    'Column3D' => 'FCF_Column3D.swf',
    'Line' => 'FCF_Line.swf',  
    'Pie2D' => 'FCF_Pie2D.swf',
    'Pie3D' => 'FCF_Pie3D.swf',
    'MSArea2D' => 'FCF_MSArea2D.swf', 
    'MSBar2D' => 'FCF_MSBar2D.swf', 
    'MSColumn2D' => 'FCF_MSColumn2D.swf',
    'MSColumn3D' => 'FCF_MSColumn3D.swf', 
    'MSLine' => 'FCF_MSLine.swf',
  );
  $format = '<option value="%s" %s>%s</option> ';
  $anchors = '<select id="chartType">';
  foreach($types as $type => $value) {
    $sel = '';
    if ($type == $t) $sel = 'selected="selected"';
    $anchors .= sprintf($format, $value, $sel, $type);
  }
  return $anchors.'</select>';  
}